function UI_CreateProgressBar ( x, y, w, h, parent )
	local ele = createElement ( "UI_ProgressBar" )
	setElementParent ( ele, parent or getResourceDynamicElementRoot ( sourceResource or getThisResource ( ) ) )

	setElementData ( ele, "UI_X", x )
	setElementData ( ele, "UI_Y", y )
	setElementData ( ele, "UI_Width", w )
	setElementData ( ele, "UI_Height", h )
	setElementData ( ele, "UI_Progress", 0 )
	setElementData ( ele, "UI_MaxProgress", 100 )
	setElementData ( ele, "UI_Alpha", 255 )
	setElementData ( ele, "UI_Theme", UI_ThemeDefault )
	setElementData ( ele, "UI_EventMouseState", false )
	
	setElementData ( ele, "UI_RenderTarget", dxCreateRenderTarget ( w > 1 and w or 1, h > 1 and h or 1, true ) )

	w = w - UI_ThemeGetWidth ( "ProgressLeft", UI_ThemeDefault ) - UI_ThemeGetWidth ( "ProgressRight", UI_ThemeDefault )
	h = h - UI_ThemeGetHeight ( "ProgressTop", UI_ThemeDefault ) - UI_ThemeGetHeight ( "ProgressBottom", UI_ThemeDefault )
	setElementData ( ele, "UI_RenderTarget2", dxCreateRenderTarget ( w > 1 and w or 1, h > 1 and h or 1 ) )

	if ( parent ) then
		if ( not UI_RenderParent[parent] ) then UI_RenderParent[parent] = {} end
		table.insert ( UI_RenderParent[parent], ele )
	else
		table.insert ( UI_Render, ele )
	end
	return ele
end

function UI_ProgressBarGetProgress ( ele )
	if ( UI_isElement ( ele ) and getElementType ( ele ) == "UI_ProgressBar" )  then
		return getElementData ( ele, "UI_Progress" ) or 0
	end
	return false
end

function UI_ProgressBarSetProgress ( ele, value )
	if ( UI_isElement ( ele ) and getElementType ( ele ) == "UI_ProgressBar" )  then
		if ( setElementData ( ele, "UI_Progress", value ) ) then
			return true
		end
	end
	return false
end

function UI_ProgressBarGetMaxProgress ( ele )
	if ( UI_isElement ( ele ) and getElementType ( ele ) == "UI_ProgressBar" )  then
		return getElementData ( ele, "UI_MaxProgress" ) or 100
	end
	return false
end

function UI_ProgressBarSetMaxProgress ( ele, value )
	if ( UI_isElement ( ele ) and getElementType ( ele ) == "UI_ProgressBar" )  then
		if ( setElementData ( ele, "UI_MaxProgress", value ) ) then
			return true
		end
	end
	return false
end

function UI_ImageGeneratorProgressBar ( ele )
	local X = getElementData ( ele, "UI_X" ) or 0
	local Y = getElementData ( ele, "UI_Y" ) or 0
	local Width = getElementData ( ele, "UI_Width" ) or 0
	local Height = getElementData ( ele, "UI_Height" ) or 0
	local Progress = getElementData ( ele, "UI_Progress" ) or 0
	local MaxProgress = getElementData ( ele, "UI_MaxProgress" ) or 100
	local MouseState = getElementData ( ele, "UI_EventMouseState" ) or false
	local RenderTarget = getElementData ( ele, "UI_RenderTarget" )
	local RenderTarget2 = getElementData ( ele, "UI_RenderTarget2" )
	local Theme = getElementData ( ele, "UI_Theme" ) or UI_ThemeDefault

	if ( Progress >= MaxProgress ) then Progress = MaxProgress end
	local ProgressBarWidth = math.floor ( ( Progress / MaxProgress ) * Width )

	dxSetRenderTarget ( RenderTarget2, true )
	ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage = UI_ThemeGetAll ( "ProgressBackground", Theme )
	dxDrawImageSection ( 0, 0, Width - UI_ThemeGetWidth ( "ProgressLeft", Theme ) - UI_ThemeGetWidth ( "ProgressRight", Theme ), Height - UI_ThemeGetHeight ( "ProgressTop", Theme ) - UI_ThemeGetHeight ( "ProgressBottom", Theme ), ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage )
	
	ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage = UI_ThemeGetAll ( "ProgressBarLitSegment", Theme )
	dxDrawImageSection ( 0, 0, ProgressBarWidth - UI_ThemeGetWidth ( "ProgressLeft", Theme ) - UI_ThemeGetWidth ( "ProgressRight", Theme ), Height - UI_ThemeGetHeight ( "ProgressTop", Theme ) - UI_ThemeGetHeight ( "ProgressBottom", Theme ), ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage )

	dxSetRenderTarget ( )

	dxSetRenderTarget ( RenderTarget, true )
	dxDrawImage ( UI_ThemeGetWidth ( "ProgressLeft", Theme ), UI_ThemeGetHeight ( "ProgressTop", Theme ), Width - UI_ThemeGetWidth ( "ProgressLeft", Theme ) - UI_ThemeGetWidth ( "ProgressRight", Theme ), Height - UI_ThemeGetHeight ( "ProgressTop", Theme ) - UI_ThemeGetHeight ( "ProgressBottom", Theme ), RenderTarget2 )
	ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage = UI_ThemeGetAll ( "ProgressTop", Theme )
	dxDrawImageSection ( UI_ThemeGetWidth ( "ProgressTopLeft", Theme ), 0, Width - UI_ThemeGetWidth ( "ProgressTopLeft", Theme ) - UI_ThemeGetWidth ( "ProgressTopRight", Theme ), ThemeHeight, ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage )
	ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage = UI_ThemeGetAll ( "ProgressTopLeft", Theme )
	dxDrawImageSection ( 0, 0, ThemeWidth, ThemeHeight, ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage )
	ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage = UI_ThemeGetAll ( "ProgressTopRight", Theme )
	dxDrawImageSection ( Width - ThemeWidth, 0, ThemeWidth, ThemeHeight, ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage )
	ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage = UI_ThemeGetAll ( "ProgressLeft", Theme )
	dxDrawImageSection ( 0, UI_ThemeGetHeight ( "ProgressTop", Theme ), ThemeWidth, Height - UI_ThemeGetHeight ( "ProgressTop", Theme ) - UI_ThemeGetHeight ( "ProgressBottom", Theme ), ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage )
	ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage = UI_ThemeGetAll ( "ProgressRight", Theme )
	dxDrawImageSection ( Width - ThemeWidth, UI_ThemeGetHeight ( "ProgressTop", Theme ), ThemeWidth, Height - UI_ThemeGetHeight ( "ProgressTop", Theme ) - UI_ThemeGetHeight ( "ProgressBottom", Theme ), ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage )
	ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage = UI_ThemeGetAll ( "ProgressBottom", Theme )
	dxDrawImageSection ( UI_ThemeGetWidth ( "ProgressBottomLeft", Theme ), Height - ThemeHeight, Width - UI_ThemeGetWidth ( "ProgressBottomLeft", Theme ) - UI_ThemeGetWidth ( "ProgressBottomRight", Theme ), ThemeHeight, ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage )
	ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage = UI_ThemeGetAll ( "ProgressBottomLeft", Theme )
	dxDrawImageSection ( 0, Height - ThemeHeight, ThemeWidth, ThemeHeight, ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage )
	ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage = UI_ThemeGetAll ( "ProgressBottomRight", Theme )
	dxDrawImageSection ( Width - ThemeWidth, Height - ThemeHeight, ThemeWidth, ThemeHeight, ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage )
	dxSetRenderTarget ( )

	return RenderTarget or nil
end

function UI_RenderButton ( ele )
	
	
end

